package com.brsya.movie.presenter;


import com.brsya.base.base.BasePresenter;
import com.brsya.base.bean.BaseObjectBean;
import com.brsya.base.net.MyObserver;
import com.brsya.base.net.RxScheduler;
import com.brsya.movie.contract.HelpContract;
import com.brsya.movie.model.HelpModel;

import java.util.Map;

/**
 * Created by Brsya
 * CreateDate: 2022/4/27  10:05
 * Description:
 * 帮助反馈
 */
public class HelpPresenter extends BasePresenter<HelpContract.View> implements HelpContract.Presenter {
    private HelpContract.Model model;

    public HelpPresenter() {
        model = new HelpModel();
    }

    @Override
    public void submit(String type, String text) {
        mView.showLoading();

        Map<String, Object> par = getPublicPar();
        par.put("type", type);
        par.put("content", text);

        model.helpSubmit(par)
                .compose(RxScheduler.Obs_io_main())
                .to(mView.bindAutoDispose())
                .subscribe(new MyObserver<BaseObjectBean<String>>(mView) {
                    @Override
                    public void success(BaseObjectBean<String> baseBean) {
                        baseBean.handleData(String.class);
                        mView.hideLoading();
                        mView.submitSuccess();
                    }
                });

    }
}
